package com.softaria.windows.seo;

import com.softaria.windows.model.PerspectiveUrl;
import com.softaria.windows.model.ViewUrl;

public class DefaultPerspectiveUrlBuilder implements PerspectiveUrlBuilder, HttpParametersConstants {

  @Override
  public PerspectiveUrl buildPerpspectiveUrl(ParameterSet parameters) {
    String perspective = parameters.getParameter(HTTP_PARAMETER_PERSPECTIVE);
    String view = parameters.getParameter(HTTP_PARAMETER_VIEW);

    PerspectiveUrl url = null;

    if (perspective != null) {

      if (view == null) {
        url = new PerspectiveUrl(perspective);
      } else {
        String view_parameters = parameters.getParameter(HTTP_PARAMETER_VIEWPARAM);
        url = new ViewUrl(perspective, view, parameters == null ? "" : view_parameters);
      }
    }

    return url;
  }

}
